public class Solution672 {
    public int flipLights(int n, int presses) {
        if (n>=3 && presses>=3){
            return 8;
        }
        if (n>=3){
            if (presses==0){
                return 1;
            }else if (presses==1){
                return 4;
            }else if (presses==2){
                return 7;
            }
        }
        if (n==2 && presses>=2){
            return 4;
        }
        if (n==1 && presses>=1){
            return 2;
        }
        int[][] f=new int[4][4];
        f[1][0]=f[2][0]=1;
        f[2][1]=3;
        return f[n][presses];
    }

    public static void main(String[] args) {
        System.out.println(new Solution672().flipLights(3,1));
    }
}
